//
//  UIColor+hf.m
//  QiBaoTong
//
//  Created by 韩艳锋 on 2019/6/17.
//  Copyright © 2019 策驭. All rights reserved.
//

#import "UIColor+hf.h"

@implementation UIColor (hf)

+(instancetype)colrWithString:(NSString*)string{
    unsigned rgbValue = 0;
    NSScanner *scanner = [NSScanner scannerWithString:string];
    // Bypass '#' character
    [scanner setScanLocation:1];
    [scanner scanHexInt:&rgbValue];
    return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0
                           green:((rgbValue & 0xFF00) >> 8)/255.0
                            blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
}

+(instancetype)coloRandom {
    return [UIColor colorWithRed:random() % 255 /255.0 green:random() % 255 /255.0 blue:random() % 255 /255.0 alpha:1];
}

+(instancetype)colrWithARGBString:(NSString*)string{
    unsigned rgbValue = 0;
    NSScanner *scanner = [NSScanner scannerWithString:string];
    // Bypass '#' character
    [scanner setScanLocation:1];
    [scanner scanHexInt:&rgbValue];
    return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0
                           green:((rgbValue & 0xFF00) >> 8)/255.0
                            blue:(rgbValue & 0xFF)/255.0
                           alpha:((rgbValue & 0xFF000000) >> 24)/255.0];
}
@end
